﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x020002BD RID: 701
public class FingerPoser : MonoBehaviour
{
	// Token: 0x06001030 RID: 4144 RVA: 0x00076F30 File Offset: 0x00075130
	public void Init(Animator anim)
	{
		this.fingerBones = new List<Transform>();
		this.fingerPoserHandles = new List<FingerPoserHandle>();
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightIndexDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightIndexIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightIndexProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightLittleDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightLittleIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightLittleProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightMiddleDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightMiddleIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightMiddleProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightRingDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightRingIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightRingProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightThumbDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightThumbIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.RightThumbProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftIndexDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftIndexIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftIndexProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftLittleDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftLittleIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftLittleProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftMiddleDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftMiddleIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftMiddleProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftRingDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftRingIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftRingProximal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftThumbDistal));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftThumbIntermediate));
		this.AddBone(anim.GetBoneTransform(HumanBodyBones.LeftThumbProximal));
	}

	// Token: 0x06001031 RID: 4145 RVA: 0x000770F7 File Offset: 0x000752F7
	private void AddBone(Transform bone)
	{
		if (bone == null)
		{
			return;
		}
		this.fingerBones.Add(bone);
		this.fingerPoserHandles.Add(this.CreateHandle(bone));
	}

	// Token: 0x06001032 RID: 4146 RVA: 0x00077124 File Offset: 0x00075324
	private void LateUpdate()
	{
		foreach (Transform transform in this.fingerBones)
		{
			transform.localRotation = this.fingerPoserHandles[this.fingerBones.IndexOf(transform)].transform.localRotation;
		}
	}

	// Token: 0x06001033 RID: 4147 RVA: 0x000771A0 File Offset: 0x000753A0
	private void OnDestroy()
	{
		foreach (FingerPoserHandle fingerPoserHandle in this.fingerPoserHandles)
		{
			UnityEngine.Object.Destroy(fingerPoserHandle.gameObject);
		}
	}

	// Token: 0x06001034 RID: 4148 RVA: 0x00077200 File Offset: 0x00075400
	public void ShowSpheres(bool isVisible)
	{
		foreach (FingerPoserHandle fingerPoserHandle in this.fingerPoserHandles)
		{
			fingerPoserHandle.gameObject.GetComponentInChildren<SphereCollider>().enabled = isVisible;
			fingerPoserHandle.gameObject.GetComponentInChildren<MeshRenderer>().enabled = isVisible;
		}
	}

	// Token: 0x06001035 RID: 4149 RVA: 0x00077278 File Offset: 0x00075478
	private FingerPoserHandle CreateHandle(Transform target)
	{
		GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>((GameObject)Resources.Load("UI/Pose/FingerPoserHandle"));
		gameObject.transform.position = target.position;
		gameObject.transform.parent = target;
		gameObject.transform.localPosition = Vector3.zero;
		gameObject.transform.localRotation = target.localRotation;
		gameObject.transform.localScale = new Vector3(10f, 10f, 10f);
		return gameObject.GetComponent<FingerPoserHandle>();
	}

	// Token: 0x040014FF RID: 5375
	private List<Transform> fingerBones;

	// Token: 0x04001500 RID: 5376
	private List<FingerPoserHandle> fingerPoserHandles;
}
